<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml" xmlns:th="http://www.thymeleaf.org">
<head>
<meta charset="UTF-8">
<title>卫戍区东城第四干休所派车管理系统</title>
<meta name="renderer" content="webkit">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<link rel="stylesheet" href="../../static/css/font.css">
<link rel="stylesheet" href="../../static/css/xadmin.css">
<script type="text/javascript" src="/static/js/jquery.min.js"></script>
<script src="../../static/lib/layui/layui.js" charset="utf-8"></script>
<script type="text/javascript" src="../../static/js/xadmin.js"></script>
<!--[if lt IE 9]>
          <script src="https://cdn.staticfile.org/html5shiv/r29/html5.min.js"></script>
          <script src="https://cdn.staticfile.org/respond.js/1.4.2/respond.min.js"></script>
        <![endif]-->
</head>
<body>
	<div class="x-nav">
		<span class="layui-breadcrumb"> <a href="">首页</a> <a href="">车辆类型管理</a>
			<!--            <a><cite>导航元素</cite></a>-->
		</span> <a class="layui-btn layui-btn-small"
			style="line-height: 1.6em; margin-top: 3px; float: right"
			onclick="location.reload()" title="刷新"> <i
			class="layui-icon layui-icon-refresh" style="line-height: 30px"></i></a>
	</div>
	<div class="layui-fluid">
		<div class="layui-row layui-col-space15">
			<div class="layui-col-md12">
				<div class="layui-card">
					<div >
						<div class="layui-card-header" hidden>
							<button class="layui-btn"
								onclick="xadmin.open('添加车辆类型','/carStatusadd',450,200)">
								<i class="layui-icon"></i>添加
							</button>
						</div>
					</div>

<!-- 					<div class="layui-btn-group demoTable">
						<button class="layui-btn" data-type="getCheckData">获取选中行数据</button>
						<button class="layui-btn" data-type="getCheckLength">获取选中数目</button>
						<button class="layui-btn" data-type="isAll">验证是否全选</button>
					</div> -->

					<table class="layui-table" id="idTest" lay-size="lg" lay-filter="demo">
					</table>

				</div>
			</div>
		</div>
	</div>
</body>
					<script type="text/html" id="barDemo">
  						<a class="layui-btn layui-btn-disabled layui-btn-xs">删除</a>
					</script>
<script>
//<a class="layui-btn layui-btn-disabled layui-btn-xs" lay-event="del">删除</a>
//table.render
     layui.use(['table','form','laypage'], function() {
		 var form = layui.from;
		 /* form.render(); */
		 var laypage = layui.laypage;
		 var table = layui.table;
		 
		//第一个实例
		  table.render({
		    elem: '#idTest'
		    ,height: 473
		    ,url: '/TCar/tcarTypenum' //数据接口
		    ,page: true //开启分页
		    ,limit: 10
		    , limits:[10,12,15]
		    ,cols: [
		    	[ //表头
		       {type:'checkbox',width:80, title: '批量操作'}
		      ,{field: 'typeName',width:200, title: '车辆类型'}
		      ,{field: 'score',width:250, title: '操作', toolbar: '#barDemo'}
		    ]
		    	]
		  ,id: 'testReload'
		  });

		 table.on('checkbox(demo)', function(obj){
			    console.log(obj)
			  });
			  //监听工具条
			  table.on('tool(demo)', function(obj){
			    var data = obj.data;
			    if(obj.event === 'detail'){
			      layer.msg('ID：'+ data.department_id + ' 的查看操作');
			    } else if(obj.event === 'del'){
			      
			    	layer.confirm('确认要删除吗？', function(index) {

						//alert(id);
							$.ajax({
								type : "delete",
								url : "/TDriver/carStatusdelete/"+data.type_num,
								data : {
									
								},
								cache : true,
								async : true,
								success: function (data){
									console.log(data);
						        	if(data.code!=20000){
										layer.msg(data.message);
									}else{
										//发异步删除数据
										obj.del();
										layer.close(index);
                                        layer.msg('已删除!', {
                                            icon : 1,
                                            time : 1000
                                        });
									}
							    },
						        error:function () {      

						        }
								
							});				
					});
			        //obj.del();
			        //layer.close(index);
			      
			    } else if(obj.event === 'edit'){
			      //layer.alert('编辑行：<br>'+ JSON.stringify(data))   
			      xadmin.open("编辑","/carStatusid?id="+data.type_num,450,200);
			    }
			    
			    
			  });
			  
			  var $ = layui.$, active = {
			    getCheckData: function(){ //获取选中数据
			      var checkStatus = table.checkStatus('idTest')
			      ,data = checkStatus.data;
			      layer.alert(JSON.stringify(data));
			    }
			    ,getCheckLength: function(){ //获取选中数目
			      var checkStatus = table.checkStatus('idTest')
			      ,data = checkStatus.data;
			      layer.msg('选中了：'+ data.length + ' 个');
			    }
			    ,isAll: function(){ //验证是否全选
			      var checkStatus = table.checkStatus('idTest');
			      layer.msg(checkStatus.isAll ? '全选': '未全选')
			    }
			  };
			  
			  $('.demoTable .layui-btn').on('click', function(){
			    var type = $(this).data('type');
			    active[type] ? active[type].call(this) : '';
			  });
     });
</script>
</html>
